var str = "fjskfjsl fjkdsjfkls fjklsfjlsd127.0.0.1fjksldfjafjio jfk192.168.1.101sljfs fsdjfkldsfjsklfsklffjoijfoiaf  asfjs fed jfjf jf sdjfsi jfi jafis function  dd ( ) { }afjsdiajf iosa function abc(){} jfisjad fjsaiofjaoissf addedfds";

//匹配ip地址
var re1 = /(\d{1,3}.\d{1,3}.\d{1,3}.\d{1,3})/g;
do{
  var result1 = re1.exec(str);
  console.log(result1 && result1[1]);
}while(result1);

//匹配函数
//匹配函数function  dd ( ) { }
var re2 = /(function\s+\w+\s*\(.{0,7}\{.{0,7}\})/g;
do{
  var result2 = re2.exec(str);
  console.log(result2 && result2[1]);
}while(result2);
